<?php

// 店铺表

namespace app\shop\model;

use think\Db;
use think\Model;

class Shop extends Model
{
    // 商铺表 商品关联
    public function ShopGoods()
    {

        return $this->hasMany('ShopGoods', 'member_id', 'member_id')->where('sun_shop_goods.status', 1)->where(['state' => 1, 'status' => 1])
            ->field('id,thumb_img,member_id,state,status')->order(['sort' => 'asc'])->limit(4);
    }

    // 店铺 会员关联
    public function Member()
    {
        return $this->hasOne('Member', 'id', 'member_id')->field('id,nickname,username');
    }


    public function ShopType()
    {
        return $this->belongsTo('ShopType', 'type_id', 'id')->field('id,title');
    }
}